import React, { useEffect, useRef } from 'react';
import { connect } from 'umi';
import { Timeline, Button } from 'antd';
import { dealtWith } from '@/common/contact';
import DrawerCondition from '@/components/DrawerCondition';
import TableDataBlock from '@/components/TableDataBlock';
import VideoUpload from '@/components/DescriptionsCondition/VideoPreview';
import ImageUpload from '@/components/DescriptionsCondition/ImagePreviewGroup';
const SetForm = (props) => {
  const { id, visible = {}, loading, list } = props;
  const childRef = useRef();
  const filterType = (e) => {
    const data = JSON.parse(e);
    const { type, content, title } = data;
    if (type === 'image') {
      return <ImageUpload url={content}></ImageUpload>;
    } else if (type === 'text') {
      return content;
    } else if (type === 'video') {
      return <VideoUpload url={content}></VideoUpload>;
    } else if (type === 'link') {
      return title;
    } else if (type === 'file') {
      return content;
    } else if (type === 'wechat') {
      return <ImageUpload url={content}></ImageUpload>;
    }
  };
  const searchItems = [
    {
      label: '状态',
      name: 'status',
      type: 'select',
      span: 12,
      select: {
        0: '未完成',
        1: '已完成',
      },
    },
  ];
  const getColumns = [
    {
      title: '开始时间',
      dataIndex: 'startTime',
    },
    {
      title: '结束时间',
      dataIndex: 'endTime',
    },
    // {
    //   title: '待办类型',
    //   dataIndex: 'content',
    //   render: (e) => {
    //     const content = JSON.parse(e);
    //     const { type } = content;
    //     return dealtWith[type];
    //   },
    // },
    {
      title: '待办',
      dataIndex: 'content',
      render: (e) => {
        return e;
      },
    },
    {
      title: '状态',
      dataIndex: 'status',
      render: (e) => {
        return {
          0: '未完成',
          1: '已完成',
        }[e];
      },
    },
  ];
  return (
    <TableDataBlock
      searchItems={searchItems}
      cRef={childRef}
      loading={loading}
      params={{
        organizationUserId: id,
      }}
      columns={getColumns}
      rowKey={(record) => `${record.id}`}
      dispatchType="subscriber/fetchListTodo"
      {...list}
    ></TableDataBlock>
  );
};

export default connect(({ loading, subscriber }) => ({
  list: subscriber.organizationUserTodoList,
  loading: loading.effects['subscriber/fetchListTodo']
}))(SetForm);
